//
//  BlindSuccessView.m
//  iiecg
//
//  Created by 123456 on 2017/12/6.
//  Copyright © 2017年 Boundary Technology. All rights reserved.
//

#import "BlindSuccessView.h"
#import "Masonry.h"

@interface BlindSuccessView()

@property (nonatomic,strong)UIImageView *backImageView;

@property (nonatomic,strong)UIImageView *ssImageView;

@property (nonatomic,strong)UILabel *dviceLabel;

@property (strong, nonatomic) UILabel *connectStatusLabel;

@end

@implementation BlindSuccessView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUpUI];
    }
    return self;
}

-(void)setName:(NSString *)name
{
    [IKPublicUtil runOnMainThread:^{
         self.backImageView.image = [UIImage imageNamed:name];
    }];
}

-(void)setDeviceString:(NSString *)deviceString
{
    if ([IKPublicUtil isEmpty:deviceString])
    {
        return;
    }
    _deviceString = deviceString;
    [IKPublicUtil runOnMainThread:^{
       self.dviceLabel.text = [INTERNATIONAL(@"string_device_id") stringByAppendingString:_deviceString];
    }];
}

-(void)setUpUI
{
    self.backImageView = [[UIImageView alloc] init];
    [self addSubview:self.backImageView];
    [self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.mas_equalTo(50);
        make.width.and.height.mas_equalTo(150);
    }];
    
    self.ssImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ecg_blind_hr"]];
    [self addSubview:self.ssImageView];
    [self.ssImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.mas_equalTo(85);
        make.width.and.height.mas_equalTo(80);
    }];
    
    UILabel *connectLab = [[UILabel alloc] init];
    [self addSubview:connectLab];
    connectLab.text = INTERNATIONAL(@"fw_connecting");
    connectLab.textAlignment = NSTextAlignmentCenter;
    connectLab.font = FONT_BASIC;
    connectLab.numberOfLines = 0;
    [connectLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.backImageView.mas_bottom).with.offset(10);
        make.left.and.right.equalTo(self);
        make.height.mas_equalTo(50);
    }];
    self.connectStatusLabel = connectLab;
    
    
    self.dviceLabel = [[UILabel alloc] init];
    self.dviceLabel.textAlignment = NSTextAlignmentCenter;
    self.dviceLabel.font = FONT_LABEL;
    self.dviceLabel.text = [INTERNATIONAL(@"string_device_id") stringByAppendingString:@""];
    self.dviceLabel.textColor = [UIColor lightGrayColor];
    [self addSubview:self.dviceLabel];
    [self.dviceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(connectLab.mas_bottom).with.offset(20);
        make.height.mas_equalTo(30);
    }];
}

- (void)connectSuccess
{
    [IKPublicUtil runOnMainThread:^{
        self.connectStatusLabel.text = INTERNATIONAL(@"string_device_bond_success");
        self.ssImageView.image = [UIImage imageNamed:@"ecg_bond_succeed"];
    }];
   
}

@end
